<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello React!</title>
<!--react核心库-->
<script src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/react/18.2.0/umd/react.production.min.js" ></script>
<!--支持react操作dom-->
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/react-dom/18.2.0/umd/react-dom.production.min.js"></script>
<!--引入babel,用于将jsx转化为js-->
<script src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/babel-standalone/6.26.0/babel.min.js" ></script>
</head>
<body>

<div id="test"></div>
    <script type="text/babel"> 

        class Weather extends React.Component{
            //初始化状态
            state = {isHot:false,wind:'小雨'}

            render(){
                const {isHot,wind} = this.state;
                return <h1 onClick={this.changeWeather}>今天天气很{this.state.isHot ? '炎热': '凉爽'},{wind}</h1>
            }

            //箭头函数是没有自己的this的，他里面的this是箭头函数外层函数的this
            //自定义方法用赋值语句+箭头函数的形式
            changeWeather = () => {
                const isHot = this.state.isHot;
                this.setState({isHot:!isHot})
            }

        }
        ReactDOM.render(<Weather/>,document.getElementById('test'))
    </script>

</body>
</html>